<%@ LANGUAGE="VBSCRIPT" %>
<% option explicit%>
<% Response.Expires=0 %>
<%

dim aa, bb,cc
aa=Request.ServerVariables("LOGON_USER")
cc=Trim(Request.Querystring("AN"))
if len(cc)=0 THEN
cc="!"& aa
cc=right(cc,24)
end if

'if instr(1,aa, cc,1)=0 THEN
'response.clear
'response.end
'end if

'aa=Request.ServerVariables("HTTP_USER_AGENT")
'bb="Indy"
'if instr(1,aa, bb,1)=0  THEN
'response.clear
'response.end
'end if
%>
<!--METADATA NAME="Microsoft ActiveX Data Objects 2.5 Library" TYPE="TypeLib" UUID="{00000205-0000-0010-8000-00AA006D2EA4}"-->
<%
dim Node, Sum, PA, CN, DTA, Ph, Ma, ChargeOFF, Ext, BS
Node=request("Node")
if isEmpty(Node) then Node="_P"
Sum=request("Sum")
if isEmpty(Sum) then Sum="0"
ChargeOFF=request("ChargeOFF")
if isEmpty(ChargeOFF) then ChargeOFF="0"
Ma=request("Ma")
if isEmpty(Ma) then Ma="0"
PA=request("PA")
if isEmpty(PA) then PA=""
CN=request("CN")
if isEmpty(CN) then CN=""
Ext=left(request("Ext"),300)
if isEmpty(Ext) then Ext=""
DTA=request("DTA")
if isEmpty(DTA) then DTA=""
Ph=request("Ph")
if isEmpty(Ph) then Ph=""

BS=request("BS")
if isEmpty(BS) then BS=0


	Dim cnn
	Dim connStr
	dim cmd
	dim R
	Set cnn=Server.CreateObject("ADODB.Connection")
'    Set cmd=Server.CreateObject("ADODB.Command")
%>
<!-- #INCLUDE FILE="Connection.inc" -->
<%
''''	connStr="Provider=SQLOLEDB.1;Persist Security Info=True;User ID=Test;Password=Test;Initial Catalog=SMS"&Node&";Data Source=EM-HOME"
	cnn.open connStr
'	Set cmd.ActiveConnection = cnn
'	cmd.CommandType=adCmdStoredProc
'	cmd.CommandText = "sp_AutomatPayment"

'	Cmd.Parameters.Append Cmd.CreateParameter("@Return_Value", adInteger, adParamReturnValue)
'	Cmd.Parameters.Append Cmd.CreateParameter("@AutomatNumber", adVarChar, adParamInput,24)
'	Cmd.Parameters.Append Cmd.CreateParameter("@Phone", adVarChar, adParamInput,20)
'	Cmd.Parameters.Append Cmd.CreateParameter("@Sum", adVarChar, adParamInput,10)
'	Cmd.Parameters.Append Cmd.CreateParameter("@Margin", adVarChar, adParamInput,10)
'	Cmd.Parameters.Append Cmd.CreateParameter("@ChargeOFF", adVarChar, adParamInput,10)
'	Cmd.Parameters.Append Cmd.CreateParameter("@Code", adVarChar, adParamInput,16)
'	Cmd.Parameters.Append Cmd.CreateParameter("@PA", adVarChar, adParamInput,36)
'	Cmd.Parameters.Append Cmd.CreateParameter("@DEMOPayment", adInteger, adParamInput)
'	Cmd.Parameters.Append Cmd.CreateParameter("@CN", adVarChar, adParamInput,160)
'	Cmd.Parameters.Append Cmd.CreateParameter("@Ext", adVarChar, adParamInput,300)
'	Cmd.Parameters.Append Cmd.CreateParameter("@DTA", adVarChar, adParamInput,20)
'	Cmd.Parameters.Append Cmd.CreateParameter("@BS", adDouble, adParamInput)
'	Cmd.Parameters.Append Cmd.CreateParameter("@id", adInteger, adParamOutput)
'	Cmd.Parameters.Append Cmd.CreateParameter("@Res", adInteger, adParamOutput)
'	Cmd.Parameters.Append Cmd.CreateParameter("@Result", adVarChar, adParamOutput,160)
'	Cmd("@AutomatNumber")=cc
'	Cmd("@Phone")=Ph
'	Cmd("@Sum")=Sum
'	Cmd("@Margin")=Ma
'	Cmd("@ChargeOFF")=ChargeOFF
'	Cmd("@Code")=Request.Querystring("Cd")
'	Cmd("@PA")=PA
'	Cmd("@DEMOPayment")=Request.Querystring("De")
'	Cmd("@CN")=CN
'	Cmd("@Ext")=Ext
'	Cmd("@DTA")=DTA
'	Cmd("@BS")=BS
'	cmd.execute

'If Cmd.Parameters("@Return_value")=0 Then	%>
<Result>
<%'=Cmd("@Result")%>
</Result>
<%
'Else
%>
<Error>
<%'=Cmd("@Result")%>
</Error>
<%
'End If
'	set cmd=nothing
	
	Dim sXML
	Dim Summa, xS, yS, zS
	
	sXML = ""'"<?xml version=""1.0"" encoding=""windows-1251""?>"
	sXML = sXML & "<Root>"
    sXML = sXML & " <Request> "
    sXML = sXML & 		" <Automat ID=""234"" Doc=""" & CN & """ PayerSmobPhone=""" & Ph & """ "
	sXML = sXML & 					"Cashcode=""" & cc & """ DateTransac=""" & DTA & """> "
    sXML = sXML & 		" <Payment GoodCode=""" & Request.Querystring("Cd") & """ "
	
	Summa = 0
	xS=Replace(Sum,".", ",")

	If IsNumeric(xS) Then
		Summa = Summa + FormatNumber(xS)
		yS=Replace(Ma,".", ",")
		zS=Replace(ChargeOFF,".", ",")
		If IsNumeric(yS) Then Summa = Summa + FormatNumber(yS)
		If IsNumeric(zS) Then Summa = Summa + FormatNumber(zS)
	End If



	Summa = Replace(Summa, ",", ".")

	sXML = sXML &					"SumReceived=""" & Summa & """ SumPayment=""" & Sum & """ SumMargin=""" & Ma & """ IsDemo=""" & Request.Querystring("De") & """ "
	sXML = sXML & 					"PA=""" & PA & """ BS=""" & BS & """/> " & Ext
    sXML = sXML & 		" </Automat> "
    sXML = sXML & 	" </Request> "
	sXML = sXML & " </Root> "

Response.Write sXML	

	Dim cmdX
    Set cmdX=Server.CreateObject("ADODB.Command")
	Set cmdX.ActiveConnection = cnn
	cmdX.CommandType=adCmdStoredProc
	cmdX.CommandText = "i_dealer.[EntranceStreamData].[usp_InputMessageToQueue]"
	CmdX.Parameters.Append CmdX.CreateParameter("@sInputMessage", adLongVarChar, adParamInput, 2000)
	CmdX.Parameters.Append CmdX.CreateParameter("@sMessage", adVarChar, adParamOutput, 500)
	CmdX("@sInputMessage")=sXML
	cmdX.execute
	set cmdX=nothing
	
	cnn.close
	set cnn=nothing
%>